package test;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import sbm.dao.UserDao;
import sbm.entity.SmbmsUser;

public class MyBatisTest2 {

	public static void main(String[] args) {

		try {
			InputStream in = Resources
					.getResourceAsStream("mybatis-config.xml");
			SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(in);
			SqlSession s = sf.openSession();
			// 获得映射的接口
			UserDao userDao = s.getMapper(UserDao.class);// !!!!!!!!
			List<SmbmsUser> li = userDao.findAll();
			for (SmbmsUser u : li) {
				System.out.println(u);
			}
			System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>");
			SmbmsUser u2 = userDao.login("李明", "0000000");
			System.out.println(u2);
			s.close();
		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}

	}

}
